package main

import (
	"fmt"
)

func sum(n1 int, n2 int) int {
	return n1+n2
}

//将函数作为形参
func test(myFunc func(int, int) int,n1 int, n2 int) int {
	return myFunc(n1,n2)
}

func multiArgs(args... int) (sum int) {
	//var sum int
	for i:=0;i<len(args);i++ {
		sum += args[i]
	}
	return
}

func main(){
	a := sum
	fmt.Printf("a的类型是%T,sum的类型是%T\n",a,sum)

	result := a(10,20)
	fmt.Println(result)

	result2 := test(a,50,60)
	fmt.Println("result2 = ",result2)

	result3 := multiArgs(10,40,30,0,9)
	fmt.Println("result3 = ",result3)
}
